package pojo;

import lombok.*;
import org.springframework.stereotype.Service;

@AllArgsConstructor
@NoArgsConstructor
@Data

public class Result<T> {
   private Integer code;
   private String message;
   private T data;

    public static <T> Result success(T data){
    Result<T> result=new Result<>(ErrorCodeEnum.SUCESS.getCode(),ErrorCodeEnum.SUCESS.getMessage(),data);
    return result;
    }
    public static <T> Result successLogin(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.SUCESSLOGIN.getCode(),ErrorCodeEnum.SUCESSLOGIN.getMessage(),data);
        return result;
    }
    public static <T> Result ErrorLogin(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.LOGIN_ERROR.getCode(),ErrorCodeEnum.LOGIN_ERROR.getMessage(),data);
        return result;
    }
    public static <T> Result successRegister(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.SUCESSREGISTER.getCode(),ErrorCodeEnum.SUCESSREGISTER.getMessage(),data);
        return result;
    }

    public static <T> Result ErrorRegister(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.REGISTER_ERROR.getCode(),ErrorCodeEnum.REGISTER_ERROR.getMessage(),data);
        return result;
    }
    public static <T> Result successReSet(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.SUCESSRESET.getCode(),ErrorCodeEnum.SUCESSRESET.getMessage(),data);
        return result;
    }
    public static <T> Result ErrorReSet(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.RESET_ERROR.getCode(),ErrorCodeEnum.RESET_ERROR.getMessage(),data);
        return result;
    }
    private static <T> Result error(T data){
        Result<T> result=new Result<>(ErrorCodeEnum.SYSTEM_ERROR.getCode(),ErrorCodeEnum.SYSTEM_ERROR.getMessage(),data);
        return result;
    }
}
